// smartlogistics/pages/warehousingitems/warehousingitems.js
const _wx = require('../../../utils/util.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    limit: 10,
    page: 1,
    warnlist: [],
    lastPage: 1,
    text: false,
    active: 1,
    actives: "a",
    num:1,
    icon: {
      active: 'https://m.bjclb.cn/assets/tabbar1.png',
      normal: 'https://m.bjclb.cn/assets/tabbar1x.png',
    },
    icon2: {
      active: 'https://m.bjclb.cn/assets/tabbar2.png',
      normal: 'https://m.bjclb.cn/assets/tabbar2x.png',
    },
    icon3: {
      active: 'https://m.bjclb.cn/assets/tabbar3.png',
      normal: 'https://m.bjclb.cn/assets/tabbar3x.png',
    },
  },
  handlepushto: function () {
    wx.redirectTo({
      url: '../../pages/warehousemanagement/warehousemanagement',
    })
  },
  handlepus: function () {
    wx.redirectTo({
      url: '../../pages/smartLogistics/smartLogistics',
    })
  },
  circulateLog() {
    const that = this
    _wx.getData('/admin/warehouse/warehousecabinetorder/select', 'GET', {
      limit: this.data.limit,
      page: this.data.page,
      borrow_status: this.data.num,
    }, function (res) {
      if (res.code == 0) {
        if (that.data.page == 1) {
          that.setData({
            warnlist: res.data,
            lastPage: res.lastPage,
            text: false
          })
        } else {
          that.setData({
            warnlist: that.data.warnlist.concat(res.data),
            lastPage: res.lastPage,
            text: false
          })
        }
      }
    });
  },
  onClick(event){
    console.log(event.detail.name);
    if(event.detail.name == "a"){
      this.setData({num:1})
      this.setData({page:1})
      this.circulateLog()
    }else if(event.detail.name == "b"){
      this.setData({num:3})
      this.setData({page:1})
      this.circulateLog()
    }else{
      this.setData({num:2})
      this.setData({page:1})
      this.circulateLog()
    }
    
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
    this.circulateLog()
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
    if (this.data.page >= this.data.lastPage) {
      this.setData({
        text: true
      })
      return false
    }
    this.setData({
      page: this.data.page + 1
    })
    this.circulateLog()
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})